#ifndef REF_GENERATOR
#define REF_GENERATOR

#include <cstdlib>
#include <stdio.h>   // Standard input/output definitions
#include <unistd.h>  // UNIX standard function definitions
#include <fcntl.h>   // File control definitions
#include <termios.h> // POSIX terminal control definitions

#include <common/mavlink.h>

#include "waypoint_list.h"



#define VERTICAL_NAVIGATOR 		1
#define HORIZONTAL_NAVIGATOR 	2
#define RANGE_UPDATE			1	//m, range to reset navigator

#ifndef HAVE_STRUCT_REF_POINT_T
#define HAVE_STRUCT_REF_POINT_T
typedef struct _ref_point_t
{
	waypoint_t position;
	float yaw;
}ref_point_t;
#endif

class ref_navigator_c
{

public:

	ref_navigator_c(float period);
	ref_navigator_c();
	~ref_navigator_c();

	float delta_x;
	float delta_y;
	float delta_z;
	float x_speed; 
	float y_speed;
	float z_speed;
	float refspeed;
	float dT;
	int direction;	//1: vertical; 2: horizontal

	ref_point_t ref_point;

	waypoint_t startpoint;
	waypoint_t endpoint;
	waypoint_t startpoint_pre;
	waypoint_t endpoint_pre;

	void horizontal_generate();
	void vertical_generate();
	void d3_generate();
	void reset(int rh, int rv);
	float mission_time_v;

private:

	float mission_time_h;	
	char flag_x;
	char flag_y;
	char flag_z;
};



#endif
